<template>
	<view>
		<view class="img" style="text-align: center; height: 220px;">
			<image src="../../static/cat-8.png" mode="" style="
			width: 250px;
			height: 250px;
			scale: 0.4;
			"></image>
		</view>


		<view class="input">

			<uni-forms ref="form" :model="user" :rules="rules">
				<uni-forms-item label="用户名" name="username">
					<uni-easyinput v-model="user.username" placeholder="请输入用户名" />


				</uni-forms-item>

				<uni-forms-item class="psw" label="密码" name="password">
					<uni-easyinput placeholder="请输入密码" type="password" v-model="user.password" />
				</uni-forms-item>

				<uni-forms-item name="">
					<button type="primary" @click="login">登录</button>
				</uni-forms-item>
			</uni-forms>

		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					username: 'dyl',
					password: '123'
				},
				rules: {

					username: {
						rules: [{
							required: true,
							errorMessage: '请输入用户名',
						}]
					},
					password: {
						rules: [{
								required: true,
								errorMessage: '请输入密码',
							},
							{
								minLength: 3,
								maxLength: 5,
								errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符',
							}
						]
					}
				},

			}
		},
		methods: {
			login(e) {
				console.log(e);
				this.$refs.form.validate()
					.then((e) => {
						console.log('校验通过');
					})
					.catch((e) => {
						console.log('校验失败');
					})

			}
		}
	}
</script>

<style scoped>
	.input {
		width: 90%;
		margin: auto !important;
	}



	/deep/ .uni-input-input {
		/* background-color: #e8f0fe; */

	}

	/deep/ .uni-input-wrapper {
		/* background-color: #e8f0fe; */
	}
</style>